//
//  ViewController.m
//  TakeScreenShot
//
//  Created by yao zhaofeng on 2018/8/2.
//  Copyright © 2018年 YaoZhaofeng. All rights reserved.
//

#import "ViewController.h"
#import "UIView+ScreenShot.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didTakeScreenshot:) name:UIApplicationUserDidTakeScreenshotNotification object:nil];
}

- (void)didTakeScreenshot:(NSNotification *)object {
    UIImage *image = [[UIApplication sharedApplication].keyWindow xy_screenshot];
    UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
    [imageView setFrame:CGRectMake(100, 100, 300, 500)];
    [self.view addSubview:imageView];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
